package vip.source.pattern.part02.improve;

import org.junit.jupiter.api.Test;
import vip.source.pattern.part02.improve.factory.impl.EGMCacheAdapter;
import vip.source.pattern.part02.improve.factory.impl.IIRCacheAdapter;
import vip.source.pattern.part02.improve.proxy.JDKProxy;
import vip.source.pattern.part02.improve.service.CacheService;
import vip.source.pattern.part02.improve.service.impl.CacheServiceImpl;

/** @Description: 抽象工厂测试 @Author: zy */
public class UnitTest {
    @Test
    public void test_CacheService() throws Exception {

        CacheService proxy_EGM = JDKProxy.getProxy(CacheServiceImpl.class, new EGMCacheAdapter());
        proxy_EGM.set("user_name_01", "开源字节");
        String val01 = proxy_EGM.get("user_name_01");
        System.out.println("测试结果：" + val01);

        CacheService proxy_IIR = JDKProxy.getProxy(CacheServiceImpl.class, new IIRCacheAdapter());
        proxy_IIR.set("user_name_01", "开源字节");
        String val02 = proxy_IIR.get("user_name_01");
        System.out.println("测试结果：" + val02);
    }
}
